
package com.shangsi.hellospringbootstarterautoconfigure.auto;

import com.shangsi.hellospringbootstarterautoconfigure.properties.HelloProperties;
import com.shangsi.hellospringbootstarterautoconfigure.service.HelloService;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 *
 * @author dzd
 * @date 2022-01-14
 */
//容器中没有配置HelloService的时候才自动配置
@ConditionalOnMissingBean(HelloService.class)
//标识为配置类是为了能够配置下方的bean
@Configuration
//开启属性文件绑定功能
@EnableConfigurationProperties(HelloProperties.class)
public class HelloServiceAutoConfigure {

    @Bean
    public HelloService helloService(){
        return new HelloService();
    }

}
